package com.zys.exercise;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class receive {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket(10086);
        byte[]bytes = new byte[1000];
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length);
        ds.receive(dp);


        byte[]data = dp.getData();
        InetAddress address = dp.getAddress();
        System.out.println("接收到的数据为"+new String(data));
        System.out.println("发送人的地址为"+address);

    }
}
